var config = require('../../../../../config');
var mongoose = require('../../../../../framework/mongoose');

var storeSchema = new mongoose.Schema({
    subscription: { type: mongoose.Schema.Types.ObjectId, ref: 'app_subscription' },
    updateTime: Date
    //categories : [{ type: mongoose.Schema.Types.ObjectId, ref: 'cms_store_category' }]
}, config.schemaOptions);
storeSchema.virtual('id').get(function() { return this._id; });
exports.CmsStore = mongoose.model('cms_store', storeSchema);

var storeCategorySchema = new mongoose.Schema({
    name: String,
    descr: { type: String, ignoreIfNull: true },
    image: String,
    store: { type: mongoose.Schema.Types.ObjectId, ref: 'cms_store' },
    updateTime: Date
    //products : [{ type: mongoose.Schema.Types.ObjectId, ref: 'cms_store_product' }]
}, config.schemaOptions);
storeCategorySchema.virtual('id').get(function() { return this._id; });
exports.CmsStoreCategory = mongoose.model('cms_store_category', storeCategorySchema);

var storeProductSchema = new mongoose.Schema({
    name: String,
    descr: { type: String, ignoreIfNull: true },
//    price: Number,
//    freight: Number,
//    flatRate: Boolean,
    thumb: String,

    order: String,
    status: Number,

    updateTime: Date,

    category: { type: mongoose.Schema.Types.ObjectId, ref: 'cms_store_category' },
    images: [{ type: mongoose.Schema.Types.ObjectId, ref: 'cmm_image' }]
}, config.schemaOptions);
storeProductSchema.virtual('id').get(function() { return this._id; });
exports.CmsStoreProduct = mongoose.model('cms_store_product', storeProductSchema);



